package com.example.star.service;

import com.example.star.entity.Star;
import com.example.star.mapper.StarMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StarService {
    @Autowired
    private StarMapper starMapper;

    public void saveStar(Star star) {
        starMapper.insertStar(star);
    }

    public List<Star> getAllStars() {
        return starMapper.getAllStars();
    }

    public List<Star> getStarsByPage(int page, int size) {
        int offset = (page - 1) * size;
        return starMapper.getStarsByPage(offset, size);
    }

    public int getTotalStars() {
        return starMapper.getTotalStars();
    }

    public void deleteStar(int id) {
        starMapper.deleteStar(id);
    }
}